Fix text extraction on DjVu so that it works beyond first call.
authorBrian Wolff <bawolff+wn@gmail.com>
Fri, 6 Dec 2013 19:39:01 +0000 (15:39 -0400)
committerBrian Wolff <bawolff+wn@gmail.com>
Fri, 6 Dec 2013 19:39:01 +0000 (15:39 -0400)
This was caching the metadata tree in-process, but it was
returning this cache even for calls for things other then this
item.

As a result, if you did $file->getHandler()->getPageText( $file, 2 )
twice in a single request, the second time it would return false.

Change-Id: I6ee4dce3177c0898e98210d7471cfadc1108ca52

includes/media/DjVu.php

index ae46b2e..cbb3ec2 100644 (file)
@@ -232,7 +232,10 @@ class DjVuHandler extends ImageHandler {
         * @return bool
         */
        function getMetaTree( $image, $gettext = false ) {
-               if ( isset( $image->dejaMetaTree ) ) {
+               if ( $gettext && isset( $image->djvuTextTree ) ) {
+                       return $image->djvuTextTree;
+               }
+               if ( !$gettext && isset( $image->dejaMetaTree ) ) {
                        return $image->dejaMetaTree;
                }